﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;

namespace FYPDemo
{
    public partial class Reward_Maintenance2 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                DataTable dt = new DataTable();
                dt = BackOffice_Maintenance.listRewardProduct("", 0, 0, 0, 2);

                RewardProduct_LV.DataSource = dt;
                RewardProduct_LV.DataBind();
            }
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            DataTable dt = new DataTable();
            int pointAbove, pointBelow, quantityBelow, Status;
            string prodName = txtRewardProdName.Text;

            if (txtPointAbove.Text == "")
                pointAbove = 0;

            else
                pointAbove = Convert.ToInt32(txtPointAbove.Text);

            if (txtPointBelow.Text == "")
                pointBelow = 0;

            else
                pointBelow = Convert.ToInt32(txtPointBelow.Text);

            if (txtQuantityBelow.Text == "")
                quantityBelow = 0;
   
            else
                quantityBelow = Convert.ToInt32(txtQuantityBelow.Text);
            
            Status = Convert.ToInt32(ddlStat.SelectedValue);

            dt = BackOffice_Maintenance.listRewardProduct(prodName, pointAbove, pointBelow, quantityBelow, Status);

            RewardProduct_LV.DataSource = dt;
            RewardProduct_LV.DataBind();
        }

        
    }
}